--TEST--
bool MySQLndUhConnection::moreResults(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function moreResults($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::moreResults($res));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function moreResults($res) {
			return $res;
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (!$conn->multi_query("SELECT '1 - without proxy' FROM DUAL; SELECT '2 - without proxy' FROM DUAL"))
		printf("[001] [%d] %s\n", $conn->errno, $conn->error);

	$i = 1;
	printf("- res %d -\n", $i++);
	do {
		if ($res = $conn->store_result()) {
			var_dump($res->fetch_all());
			$res->free();
		}
		if ($conn->more_results()) {
			printf("- res %d -\n", $i++);
		}
	} while ($conn->more_results() && $conn->next_result());

	mysqlnd_uh_set_connection_proxy(new proxy());
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (!$conn->multi_query("SELECT '1 - with proxy' FROM DUAL; SELECT '2 - with proxy' FROM DUAL"))
		printf("[002] [%d] %s\n", $conn->errno, $conn->error);

	$i = 1;
	printf("- res %d -\n", $i++);
	do {
		if ($res = $conn->store_result()) {
			var_dump($res->fetch_all());
			$res->free();
		}
		if ($conn->more_results()) {
			printf("- res %d -\n", $i++);
		}
	} while ($conn->more_results() && $conn->next_result());

	mysqlnd_uh_set_connection_proxy(new proxy2());
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (!$conn->multi_query("SELECT '1 - with proxy2' FROM DUAL; SELECT '2 - with proxy2' FROM DUAL"))
		printf("[002] [%d] %s\n", $conn->errno, $conn->error);

	$i = 1;
	printf("- res %d -\n", $i++);
	do {
		if ($res = $conn->store_result()) {
			var_dump($res->fetch_all());
			$res->free();
		}
		if ($conn->more_results()) {
			printf("- res %d -\n", $i++);
		}
	} while ($conn->more_results() && $conn->next_result());


	print "done!";
?>
--EXPECTF--
- res 1 -
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(17) "1 - without proxy"
  }
}
- res 2 -
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(17) "2 - without proxy"
  }
}
- res 1 -
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(14) "1 - with proxy"
  }
}
proxy::moreResults(array (
  0 => NULL,
))
bool(true)
- res 2 -
proxy::moreResults(array (
  0 => NULL,
))
bool(true)
proxy::moreResults(array (
  0 => NULL,
))
bool(true)
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(14) "2 - with proxy"
  }
}
proxy::moreResults(array (
  0 => NULL,
))
bool(false)
proxy::moreResults(array (
  0 => NULL,
))
bool(false)
- res 1 -
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(15) "1 - with proxy2"
  }
}

Warning: mysqli::more_results(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d
- res 2 -

Warning: mysqli::more_results(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d

Warning: mysqli::next_result(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d
array(1) {
  [0]=>
  array(1) {
    [0]=>
    string(15) "2 - with proxy2"
  }
}

Warning: mysqli::more_results(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d
- res 3 -

Warning: mysqli::more_results(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d

Warning: mysqli::next_result(): (MySQLnd User Handler) The method MySQLndUhConnection::moreResults() did not return a boolean value as it should in %s on line %d
done!